<!doctype html>
<html>
<head>
    <title>订单列表页面</title>
    <?php $this->load->module('admin/index/page_header');?>
    <link href="<?php echo URLPRE;?>static/admin/css/font_icon.css" rel="stylesheet" />
    <script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/Kalendajs/build/kalendae.standalone.js"></script>
    <link href="<?php echo URLPRE;?>static/public/Lib/Kalendajs/build/kalendae.css" rel="stylesheet" />
</head>
<body>

<style>
    .wrap{background: #f2f6f8;width: 99%;margin: 0 auto;padding: 10px 10px 200px 10px }
    .index-page-title{font-size:25px;text-align: center;display: block;padding-bottom:2px;color: #34495E;}
    .index-page-time{font-size:18px;text-align: center;display: block;padding:2px;margin-top:11px;color: #666;}
    .table_list{
        margin-top: 10px;
        overflow: hidden;
        background: #fafafa;
        -webkit-box-shadow: 0px 0px 9px 2px rgba(191,187,191,0.35);
        -moz-box-shadow: 0px 0px 9px 2px rgba(191,187,191,0.35);
        box-shadow: 0px 0px 9px 2px rgba(191,187,191,0.35);
        padding: 10px;

    }

    .table_list tr{
        height: 45px;
    }
    .table_list .tr-title-wrap ,.table_list .tr-title-wrap:hover td{background: #34495E;color: #fff;}

    .table_list .tr-title-wrap td:hover{background-image: none}

    .input, textarea, select {
        padding: 9px 4px;
        font-size: 100%;

    }

    .export-button{ margin-left: 20%;}

</style>
<script>
    $(function(){
        //setInterval("$('#currentTime').text(new Date().toLocalsString());",1000);
        setInterval(function(){
            $("#currentTime").text(new Date().toLocaleString());
        },1000);
    });

</script>
<div class="wrap J_check_wrap">

    <h1 class="index-page-title">房间库存查询</h1>
    <span class="index-page-time">现在时间：<span id="currentTime"></span></span>



<!--    --><?php //if(TADMIN):?>

<!--    --><?php //endif;?>
    <div  >
        <table width="100%" class="table_list">
            <tbody>
            <tr>
                <td>
             开始日期  &nbsp;<input type="text" class="input rounded" value="<?php echo  $start;?>" placeholder="请选择开始日期" name="start_date" id="start_date" readonly />

                &nbsp;&nbsp;

           结束日期   &nbsp;<input type="text" class="input rounded" data-default="<?php echo $end;?>" placeholder="请选择结束日期"  value="<?php echo  $end;?>" name="end_date" id="end_date" readonly />

                    &nbsp;&nbsp;
                    &nbsp;&nbsp;


                    <input type="submit" class="btn" value="搜索">

                    <?php if(!check_wap()):?>
                          <input type="button" class="btn btn_submit  export-button" onclick="window.location.href='<?php echo $export_url;?>'" value="导出excel">
                    <?php endif;?>

            </tr>
            </td>
            </tbody>
        </table>

        <table width="100%" style="display: none" class="table_list">
            <tbody>
            <tr class="tr-title-wrap">

                <td width="5%">可选</td>
                <td >房间号</td>
                <td>已经入住日期</td>
                <td width="8%">可入住人数</td>
                <td>备注</td>
                <td>联系人信息</td>
            </tr>

            <?php if($room_list):?>
                <?php foreach ($room_list as $key=>$item):?>
                    <tr class="js-input-room-check">
                        <td> <?php if (in_array($item['id'],$lock_room)):?><span class="red"> 满房</span>
                            <?php else:?>
                            <span class="green"><a href="<?php echo site_url('order/adminhotel/add');?>">可预定</a></span>
                            <?php endif;?> </td>
                        <td><?php echo $item['name'];?></td>
                        <td>
                            <?php if(!empty($lock_key_date[$item['id']])):?>
                                <?php echo implode(',', $lock_key_date[$item['id']]);?>
                            <?php else: ?>
                                未入住
                            <?php endif;?>
                        </td>
                        <td><?php echo $item['number'];?></td>
                        <td><?php echo $item['note'];?></td>
                        <td>
                            <?php if($item['contact_list']):?>

                                <?php foreach ($item['contact_list'] as $i=>$v):?>
                                    <div class="mb5">
                                        <span class="mr15">联系人：<?php echo $v['name'];?></span><br />
                                        <span class="mr15">手机号码：<?php echo $v['phone_num'];?></span><br />
                                    </div>

                                <?php endforeach;?>

                            <?php endif;?>
                        </td>
                    </tr>
                <?php endforeach;?>
            <?php endif;?>

            </tbody>
        </table>

        <style>
            .table_list_store{width: 98%;margin: 20px auto;}
            .table_list_store td{
                width: 16.666666666667%;
                text-align: center;
                line-height: 18px;
                height: 35px;
                vertical-align: top;
                border: solid 1px #e1e1e1;
                color: #666;
                font-size: 14px;
                padding: 0;
                opacity: 1!important;
                filter: Alpha(Opacity=100);
            }

            .table_list_store .td-green{background:#4CAF50;color: #fff;}
            .table_list_store .td-red{background: #E53935;color: #fff;}
            .table_list_store .item-link a{
                display: block;    background: #F57C00;
                color: #fff;
                width:60px;
                height:28px;
                line-height: 28px;
                border-radius:5px;margin: 5px auto;}
            .table_list_store p{font-size:15px;display:block;margin: 10px 0;}
        </style>


        <table class="table_list_store">
            <tbody>

            <?php if($room_list):?>
                <?php foreach ($room_list as $key=>$item):?>

                    <!--                --><?php //if($key == 0 || ($key+1)%7 == 0):?><!--<tr>--><?php //endif;?>
                    <?php if (in_array($item['id'],$lock_room)):?>
                        <td class="td-red">
                            <p class="item-title"><?php echo $item['name'];?></p>
                            <p class="item-dates">	 <?php if(!empty($lock_key_date[$item['id']])):?>
                                    <?php echo implode(',', $lock_key_date[$item['id']]);?>
                                <?php endif;?></p>
                            <p class="item-contact">
                                <?php if($item['contact_list']):?>

                                    <?php foreach ($item['contact_list'] as $i=>$v):?>

                                        <p><!--联系人：--><?php echo $v['name'];?></p>
                                        <p><!--手机号码：--><?php echo $v['phone_num'];?></p>


                                    <?php endforeach;?>

                                <?php endif;?>
                            </p>
                        </td>
                    <?php else:?>
                        <td class="td-green">
                            <p class="item-title"><?php echo $item['name'];?></p>
                            <p class="item-dates"><?php echo $item['note'];?></p>
                            <p class="item-link"><a href="<?php echo site_url('order/adminhotel/add');?>">可预订</a></p>
                        </td>
                    <?php endif;?>
                    <?php if(($key+1)%6 == 0):?></tr><?php endif;?>

                <?php endforeach;?>
            <?php endif;?>


            </tbody>
        </table>
    </div>
    <script>

        var urlD = '<?php echo site_url('order/adminhotel/room_repertory');?>';
        new Kalendae.Input('start_date', {
            months:1,
            mode:'single',
            format:'YYYY-MM-DD',
            direction:'today-future'
        });


        new Kalendae.Input('end_date', {
            months:1,
            mode:'single',
            format:'YYYY-MM-DD',
            direction:'future'
        });



        $('#start_date').change(function () {


            var date = $(this).val();
            var month = '';
            var day = '';
            d = new Date(date);
            d = +d + 1000*60*60*24;
            d = new Date(d);



            if((d.getMonth()+1).toString().length == 2){
                month = (d.getMonth()+1);
            }else {
                month = '0'+(d.getMonth()+1);
            }

            if(d.getDate().toString().length == 2){
                day = d.getDate();
            }else {
                day = '0'+(d.getDate());
            }

            var newdate = d.getFullYear()+"-"+month+"-"+day;




            $('#end_date').val(newdate);



            var end = $('#end_date').val();
            var df_date = $('#end_date').data('default');

            if(end !== df_date)
            {
                var url = urlD+'?start='+date+'&end='+end ;
                $.dialog.tips('加载中...');
                window.location.href = url;
            }


        })

        $('#end_date').change(function () {

            var start = $('#start_date').val();
            var end = $('#end_date').val();
            var url = urlD+'?start='+start+'&end='+end ;
            $.dialog.tips('加载中...');
            window.location.href = url;

        })
    </script>
</div>
</body>
</html>